<template>
  <div>
    <!-- 商品 -->
    <div class="commodity">
      <div>
        <div class="van-card" v-for="item in getproducthome" :key="item.p_id">
          <img :src="item.pro_img_url" alt="" />
          <p class='pshen'>
            <span class="slhsss">{{item.p_title}}</span>
          </p>
          <p>
            <span class="imgfll">￥{{item.p_price_cur}}</span>
            <span class="imgfr">{{item.p_stock}}<img src="./../../assets/HomeImg/8.png" alt=""
                style="width:12px;height:12px;"></span>
          </p>
          <van-button class='buttbb' :to="'/details/'+item.p_id">立即购买</van-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    // props: ['dataList'],
    data: () => ({
      getproducthome: []
      // addproducthome: [],
      // addproductimghome: []
    }),
    created() {
      // this.GetProductHome()
      // this.addProduct()
      // this.addProductImg()
      console.log(this.dataList)
      this.GetProductHome()
    },
    methods: {
      async GetProductHome() {
        try {
          const {
            data
          } = await this.$Api.apiHome.GetProductHome()
          this.getproducthome = data
          console.log('getproducthome',data)
        } catch (error) {
          this.$Toast(error)
        }
      }
    }
  }

</script>
<style lang="less" scoped>
  // 商品插件样式
  .commodity {
    width: 100%;
    height: 100%;
    background: #EFEFEF;
    overflow: hidden;
    text-align: center;
    padding: 0 0 0 2%;
    padding-bottom: 54px;


    .van-card {
      float: left;
      width: 47%;
      min-height: 100px;
      box-sizing: border-box;
      margin: 2% 2% 0 0;
      padding: 0;

      img {
        width: 100%;
        margin: 0;
        border-radius: 3px;
      }

      .pshen {
        margin: 0;
        // width: 200px;

        .slhsss {
          // max-width: 86%;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
          overflow: hidden;
          word-break: break-all;
        }
      }

      .imgfll {
        float: left;
      }

      .imgfr {
        float: right;
      }

      .buttbb {
        width: 92%;
        height: 35px;
        border-radius: 4px;
        margin-bottom: 3%;
        color: #fff;
        background: rgb(255, 87, 119);
        border: 0;
      }
    }
  }

</style>
